<?php
/**
 * Maintenance Screen
 */

// Custom Part
use Fox\Generator;
use Common\Competitor;
$finder = new Competitor();
$idFieldName = array_keys($finder->getIds());
$idFieldName = $idFieldName[0];
$module = "competitors";
$title = "Concurrents";// Xview::instance()->pageTitle();
$orderBy = array("name" => false);
// Standard Maintenance List
$result = $finder->find(null,$orderBy);
$grid = new Fox\Grid("gList");
$grid->fieldcat(array(array("keyid",$idFieldName),array("competitor","name"),"iedit","idele"));
$grid->fieldcat()->field($idFieldName)->noOutput();
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->setGenerators(array(
	'idele' => Generator::display('popForm', Fox\Generator::url(
		'maintenance',
		$module,
		'delete',
		array(
			"id" => Fox\Generator::useAttribute($idFieldName)
		)
	)),
	'iedit' => Fox\Generator::display('popForm', Fox\Generator::url(
		'maintenance',
		$module,
		'edit',
		array(
			"id" => Fox\Generator::useAttribute($idFieldName)
		)
	))
));
$grid->initialize($result);
$grid->footer()->add(new Fox\Html\Button("add",Generator::display('add',Generator::url('maintenance',$module,'edit'))));
echo "<h1>".$title."</h1>";
echo Xview::instance()->messages();
echo "<br>";
echo $grid->Display();